package java_05;

import java.util.HashSet;
import java.util.Set;

public class java_05 {
	public static void main(String[] args) {
		int[] arr1={1,2,3};
		int[] arr2={3,4,5,2};
		int[] result = removeint(arr1, arr2);
		for(int i:result){
			System.out.print(i+" ");
		}
	}
	private static int[] removeint(int[] arr1, int[] arr2) {
		HashSet<Integer> set1 = new HashSet<>();
		for(int i:arr1){
			set1.add(i);
		}
		Set<Integer> set2 = new HashSet<>();
		for (int num : arr2) {
			set2.add(num);
		}
		HashSet<Integer> onlyarr1=new HashSet<>(set1);
		HashSet<Integer> onlyarr2=new HashSet<>(set2);
		onlyarr1.removeAll(set2);
		onlyarr2.removeAll(set1);
		Set<Integer> resultSet = new HashSet<>();
		resultSet.addAll(onlyarr1);
		resultSet.addAll(onlyarr2);
		int[] resultArray = new int[resultSet.size()];
		int index = 0;
		for (int num : resultSet) {
			resultArray[index++] = num;
		}
		return resultArray;
	}
}
